//
//  Test_inheritance2.hpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/13.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef Test_inheritance2_hpp
#define Test_inheritance2_hpp

#include <stdio.h>
#include <iostream>
class Base6
{
public:
    int m_x;
    
public:
    Base6(int x): m_x(x)
    {
        std::cout << "Base()\n";
        
    }
    ~Base6()
    {
        std::cout << "~Base()\n";
    }
    
    void print() { std::cout << "Base: " << m_x << '\n';  }
};

class Derived4: public Base6
{
public:
    Derived4(int y):  Base6(y)
    {
        std::cout << "Derived()\n";
    }
    ~Derived4()
    {
        std::cout << "~Derived()\n";
    }
    
    void print() { std::cout << "Derived: " << m_x << '\n'; }
};

class D2 : public Derived4
{
public:
    D2(int z): Derived4(z)
    {
        std::cout << "D2()\n";
    }
    ~D2()
    {
        std::cout << "~D2()\n";
    }
    
    // note: no print() function here
};

/*
 
 D2 d = D2(3);
 d.print();//Derived: 3
 d.Base6::print();//Base: 3
 
 */

#endif /* Test_inheritance2_hpp */
